﻿cmake_minimum_required(VERSION 2.8)
project(libssh2)
file(GLOB lib_hdrs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/*.h)
file(GLOB_RECURSE lib_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.c)
set(CMAKE_DEBUG_POSTFIX "D")
list(APPEND lib_libs ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ws2_32)
include_directories(${ZLIB_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${OPENSSL_SOURCE_DIR}/../include include)
add_definitions(/DLIBSSH2_HAVE_ZLIB=1 /DLIBSSH2_OPENSSL /DLIBSSH2_DH_GEX_NEW=1 /DLIBSSH2_WIN32 /DLIBSSH2_CLEAR_MEMORY)
add_library(${PROJECT_NAME} SHARED ${lib_srcs} src/${PROJECT_NAME}.rc)
target_link_libraries(${PROJECT_NAME} ${lib_libs})
install(FILES ${lib_hdrs} DESTINATION include)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)

if(BUILD_STATIC)
  add_library(${PROJECT_NAME}S STATIC ${lib_srcs})
  install(TARGETS ${PROJECT_NAME}S EXPORT ${PROJECT_NAME}S-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
  install(EXPORT ${PROJECT_NAME}S-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}S-config.cmake)
endif()
